<!-- <template>
  <div class="PlanManagementPreview">
    <div class="flex location-wrap">
        <span class="white">当前位置：</span>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/EmergencyPlan' }">应急预案</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '/PlanManagement' }">预案管理</el-breadcrumb-item>
        <el-breadcrumb-item>预览</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <Preview :base="base" :url="url" @download="getDownload"></Preview>

  </div>
</template>

<script>
import { getByIdApi } from "@/api/EmengercyPlan/yagl";
import { loadFile } from "@/api/common.js";
import Preview from "../components/Preview";

export default {
  name: "PlanManagementPreview",
  components: {
    Preview
  },
  data() {
    return {
      // base: "http://192.168.0.193:9000/",
      base: "http://192.168.0.206:19000/",
      url: "",
      accessoryId: [],
      attachId: ""
    };
  },
  created() {
    // this.url = this.base + "demo/demo1.docx";
  },
  mounted() {
    this.getById();

  },
  methods: {
    getById() {
      console.log("route", this.$route.query.id);
      getByIdApi({ id: this.$route.query.id }).then(res => {
        console.log("getById", res);
        this.accessoryId = res.accessoryId;
        this.attachId = res.accessoryId[0].attachId;
        // this.attachId = res.fileIdInfo.length ? res.fileIdInfo[0].attachId : "";
        console.log("attachId", this.attachId);

        loadFile({ id: this.attachId }).then(data => {
          console.log("data", data);
          // window.open(data);
          this.url = data;
          // this.base = data.slice(0, 26);
          console.log("base", this.base);
        });
      });
    },
    getDownload() {
      getByIdApi({ id: this.$route.query.id }).then(res => {
        this.accessoryId = res.accessoryId;
        this.attachId = res.accessoryId[0].attachId;
        loadFile({ id: this.attachId }).then(data => {
          window.open(data);
        });
      });
    }
  }
};
</script>

<style lang='less' scoped>
@import "../../../assets/style/common.less";
@import "../../../assets/style/ComponentStyle.less";
@import "../../../assets/style/pop-upNotification.less";

.PlanManagementPreview {
  height: 100%;
  :deep(.el-breadcrumb__inner.is-link) {
    font-weight: 100;
    font-size: 16px;
    color: #fff;
  }
  :deep(.el-breadcrumb__item:last-child .el-breadcrumb__inner) {
    font-size: 16px;
    color: #3270ff;
  }
}
</style> -->
